package com.audaque.springboot.foshanupload.web.kafkademo.handler;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.Consumer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.listener.ConsumerAwareListenerErrorHandler;
import org.springframework.kafka.listener.ListenerExecutionFailedException;
import org.springframework.messaging.Message;

/**
 * @author zgb
 * @desc ...
 * @date 2023-08-28 19:16:31
 */
@Slf4j
@Configuration
public class ConsumerAwareListenerErrorHandlerConfig {
    @Bean
    public ConsumerAwareListenerErrorHandler consumerAwareErrorHandler() {
        return new ConsumerAwareListenerErrorHandler() {

            @Override
            public Object handleError(Message<?> message, ListenerExecutionFailedException e, Consumer<?, ?> consumer) {
                log.debug("consumerAwareErrorHandler receive : "+message.getPayload().toString());
                return null;
            }
        };
    }

}
